#include "ros/ros.h"
#include "std_msgs/String.h"
#include <custom_msg/CMD.h>
#include <iomanip>
#include "commons/rabbit_consts.h"

using namespace std;
custom_msg::CMD CMD_data;  //全局变量，解析后数据

//test rostipc pub ;./listener_sumboy 1 101 ; rostopic echo /sensors/cmd
int main(int argc, char** argv) {
  int len, Rece_out;
  ros::init(argc, argv, "serial_pub_sumboy");
  ros::NodeHandle nh;
  ros::Publisher CMD_pub = nh.advertise<custom_msg::CMD>(TOPIC_CMD, 1000);
  ros::Rate loop_rate(10);
  int i = 0;
  int cmd_type = atoi(argv[1]);
  int val_type = atoi(argv[2]);
 cout << "cmd_type:" << cmd_type<< "val_type:" << val_type<< "\r\n";
  while (true) {
      if(i>=5){
          break;
      }
      CMD_data.header.stamp = ros::Time::now(); 
      CMD_data.cmd_type = cmd_type;
      CMD_data.val_type = val_type;
      CMD_pub.publish(CMD_data);
      ros::spinOnce();
      loop_rate.sleep();
      i++;
  }
}


